<template>
	<div class="addressEdit">
		<AddressHead>新增地址</AddressHead>
		<!-- <div class="my_head">
			<div class="my_back" @click="$router.go(-1)">
			</div>
			新增地址
		</div> -->
		<div class="edit">
			<van-address-edit
			  :area-list="areaList"
			  show-postal
			  :address-info="addressInfo"
			  show-delete
			  show-set-default
			  show-search-result
			  :search-result="searchResult"
			  :area-columns-placeholder="['请选择', '请选择', '请选择']"
			  @save="onSave"
			  @delete="onDelete"
			  @change-detail="onChangeDetail"
			/>
		</div>
		
	</div>
</template>

<script>
	import AddressHead from '../../../components/Head2.vue'
	import Vue from 'vue';
	import { AddressEdit } from 'vant';
	Vue.use(AddressEdit);
	import { areaList } from '@vant/area-data';
	import { Toast } from 'vant';
	
	export default {
		components:{
				  AddressHead
		},
	   data() {
	      return {
	        areaList,
	        searchResult: [],
			addressInfo:{
			}
	      };
	    },
	  methods: {
	    onSave(e) {
	      Toast('save');
		  // console.log(e)
		  this.$http.post('/address/addressup',{
			  e,
			  u_id:this.$store.state.u_id
		  }).then(res=>{
			  // console.log(res)
			  if(res.data.code==200){
				  this.$router.go(-2)
			  }
		  })
	    },
	    onDelete() {
	      Toast('delete');
	    },
	    onChangeDetail(val) {
	      if (val) {
	        this.searchResult = [
	          {
	            name: '黄龙万科中心',
	            address: '杭州市西湖区',
	          },
	        ];
	      } else {
	        this.searchResult = [];
	      }
	    },
	  },
	};
</script>

<style>
	.edit{
		margin-top: 3.4375rem;
	}
</style>
